<div id="pages_login_login" class="scroll" style="height:100%;display:none;"><div class="loginBox">
  <div v-if="logo" class="logo"><img class="logoImg" mode="aspectFit" :src="logo"></img></div>
  <formitems :models="models" ref="loginForm"></formitems>
  <button_ class="loginBtn" type="primary" size="default" :disabled="submiting" @click="submit">{{submiting ? '登录中...' : '登录'}}</button_>
</div></div>
<script type="text/javascript">
(function (G) {
  G.vue("pages_login_login",{
  "usingComponents": {
    "formitems":"/components/Form/Items/Items"
  },
  "navigationBarTitleText": "登录"
},{
    noLogin:true,
    data:{
      logo:G.Storage.get('logo'),
      models:{
        userName:{
          type: 'input',
          label: '用户名',
          rule: { NotNull: true }
        },
        passWord:{
          label: '密码',
          type: 'input',
          attr: { type: 'password' },
          rule: { NotNull: true }
        }
      },
      submiting: false
    },
    methods:{
      submit:function(){
        var _this = this;
        var data = this.selectComponent('#loginForm').submit();
        if(!data) return false;
        data.passWord = G.MD5(data.passWord);
        data.platform = G.platform;
        this.setData({submiting:true});
        G.ajax('/login',function(ret){
          _this.setData({ submiting: false });
          if(!ret.errorMsg){
            G.Storage.set('user', ret, 1);
            var activeGroupId = G.Storage.get('groupId', 1);
            G.Storage.remove('groupId');
            var hasActive = false;
            for (var i = 0; i < ret.groups.length; i++) if (activeGroupId == ret.groups[i].groupId) hasActive = true;
            if (!hasActive && ret.groups[0]) activeGroupId = ret.groups[0].groupId;
            G.Storage.set('groupId', activeGroupId, 1);
            G.Storage.get('autoLogin')(function () {
              G.$go(G.Storage.get('loginRedirectTo') || '/pages/index/index', 'redirectTo')
            })
          }
        },{
          meth:'POST',
            data: data
        })
      }
    }
  });
})(Y)

</script>